<?php


function thumb(){
			$old=getimagesize("1.jpg");
			$new_width=$old[0]/2;
			$new_height=$old[1]/2;

			print_r($old);
			switch ($old[2]) {
				case '1':
					$old_img=imagecreatefromgif('1.jpg');
					break;
				case '2':
					$old_img=imagecreatefromjpeg('1.jpg');
					break;	
				case '3':
					$old_img=imagecreatefrompng('1.jpg');
					break;		
				default:
					break;
			}


			$new_img=imagecreatetruecolor($new_width,$new_height);
			imagecopyresized($new_img,$old_img,0,0,0,0,$new_width,$new_height,$old[0],$old[1]);
			ob_clean();

			switch ($old[2]) {
				case '1':
					imagegif($new_img,'thumb.jpg');
					break;
				case '2':
					imagejpeg($new_img,'thumb.jpg');
					break;	
				case '3':
					imagepng($new_img,'thumb.jpg');
					break;		
				default:
					break;
			}

			imagedestroy($new_img);
}